package com.qihoo360.mobilesafe.opti.powerctl;

import com.qihoo360.mobilesafe.opti.powerctl.ui.widget.BtyAniView;
import com.qihoo360.mobilesafe.opti.powerctl.ui.widget.RotatePointerAniView;
import com.qihoo360.mobilesafe.opti.powerctl.ui.widget.RotateScanAniView;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.widget.Button;

public class PowerCtrlActivity extends Activity implements OnClickListener {
	private BtyAniView view;
	private RotateScanAniView mScanView;
	private RotatePointerAniView mRotateView;
	private Button mShow;
	private Button mCharging;
	private Button mLowCharging;
	
	private Button mStartScan;
	private Button mStopScan;
	private Button mStartRotate;
	private int degree = 0;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);
		view = (BtyAniView) findViewById(R.id.battery);
		view.initAnimation();
		mScanView = (RotateScanAniView) findViewById(R.id.scan);
		mRotateView = (RotatePointerAniView) findViewById(R.id.rotate);
		mShow = (Button) findViewById(R.id.showBattery);
		mShow.setOnClickListener(this);
		mCharging = (Button) findViewById(R.id.charging);
		mCharging.setOnClickListener(this);
		mLowCharging = (Button) findViewById(R.id.low_charging);
		mLowCharging.setOnClickListener(this);
		mStartScan = (Button) findViewById(R.id.start_scan);
		mStartScan.setOnClickListener(this);
		mStopScan = (Button) findViewById(R.id.stop_scan);
		mStopScan.setOnClickListener(this);
		mStartRotate = (Button) findViewById(R.id.start_rotate);
		mStartRotate.setOnClickListener(this);
	}

	@Override
	public void onClick(View v) {
		switch(v.getId()) {
		case R.id.showBattery:
			view.showBatteryStatus();
			break;
		case R.id.charging:
			view.isCharging();
			break;
		case R.id.low_charging:
			view.isLowCharging();
			break;
		case R.id.start_scan:
			mScanView.startScan();
			break;
		case R.id.stop_scan:
			mScanView.stopScan();
			break;
		case R.id.start_rotate:
			degree = degree+ 30;
			mRotateView.start(degree++);
			break;
		}
	}
}